package com.bear.newsset.entity;

import com.ybear.networkutil.request.Param;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * 基础实体类
 *
 */
public class BaseEntity extends Param implements Serializable {
    public Map<String, String> toMap() {
        Map<String, String> map = new HashMap<>();
       Field[] fields = getClass().getDeclaredFields();
       try {
           for (Field field : fields) {
              field.setAccessible(true);
              Object val = field.get( this );
              map.put(field.getName(), val == null ? "" : val.toString());
           }
       } catch (Exception e) {
           e.printStackTrace();
       }
       return map;
    }
}